cmake_minimum_required(VERSION 3.5)
project(spi_service)

set(TOOLCHAIN_PATH /usr)
set(tools /usr)
set(CMAKE_C_COMPILER ${tools}/bin/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/aarch64-linux-gnu-g++)

include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}/include
)

# Default to C99
if(NOT CMAKE_C_STANDARD)
  set(CMAKE_C_STANDARD 99)
endif()

# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
  set(CMAKE_CXX_STANDARD 17)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  add_compile_options(-Wall -Wextra -Wpedantic)
endif()

# find dependencies
find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(geometry_msgs REQUIRED)

if(BUILD_TESTING)
  find_package(ament_lint_auto REQUIRED)
  ament_lint_auto_find_test_dependencies()
endif()

# file(GLOB IPC_SKELETON_SRC               "${CMAKE_CURRENT_SOURCE_DIR}/*.cpp")
file(GLOB NEDIATOR_CONTRE_SRC            "${CMAKE_CURRENT_SOURCE_DIR}/src/Maxieye_Spi_Mediator_Contre/*.cpp")
file(GLOB SPI_DEV_SRC                    "${CMAKE_CURRENT_SOURCE_DIR}/src/Spi_Dev_Management/*.cpp")
set(NETWORK_SOURCE
        ${NEDIATOR_CONTRE_SRC}
        ${SPI_DEV_SRC}
)

file(GLOB UTILITIES_SRC                    "${CMAKE_CURRENT_SOURCE_DIR}/src/Utilities/*.cpp")

add_executable(${PROJECT_NAME} 
  src/main.cpp
  ${NETWORK_SOURCE}
  ${UTILITIES_SRC}
)
ament_target_dependencies(${PROJECT_NAME}  rclcpp geometry_msgs)

install(TARGETS
  ${PROJECT_NAME} 
  DESTINATION lib/${PROJECT_NAME}
)

ament_package()
